package com.songlanyun.modules.exception;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.songlanyun.common.drive.IntegerEnum;

import java.util.Objects;

public enum OrderException  implements IntegerEnum<Integer>
{
    ORDER_NOT_EXISTS(30001, "订单不存在"),
    ORDER_NOT_GOODS(30009, "下单时一定选择商品"),
    ORDER_NOT_SHOP(30010, "下单时一定要选择店铺"),
    ORDER_NOT_EXPRESS(30011, "下单是选择快递需要提供收货人信息"),
    ORDER_NOT_PICK_UP(30012, "下单是选择自提需要提供提货人信息"),
    PAY_ORDER_NOT_EXISTS(30013, "支付订单不存在"),
    NOT_REPEAT_PAY(30014, "支付订单已成功支付,不能重复"),
    PAY_SUCCESS_NOT_CLOSE(30015, "支付订单已成功支付,不能关闭"),
    PAY_ORDER_CLOSED(30016, "支付订单已关闭,不能取消支付"),
    PAY_ORDER_CLOSED_NOT_PAY(30017, "支付订单已关闭,不能支付"),
    CHILD_ORDER_NOT_EXISTS(30018, "子订单不存在"),
    SHIPPING_ADDRESS_NOT_EXISTS(30019, "收货地址不存在不能下单"),
    ORDER_NOT_PAY(30020,"订单未支付"),

    USER_CART_EXISTS(30021, "用户的购物车产品不存在"),
    PAY_EXPIRED(30022, "支付已过期"),
    SHIP_REPEAT(30023, "已发货不要重复发货"),
    STOCK_UP_REPEAT(30023, "已备货完成不要重复备货"),
    PACKAGE_NOT_EXISTS(30024, "订单的发货信息不存在"),
    RECEIPT_COMPLETE(30025, "收货已完成,不能再发货"),
    RECEIPT_REPEAT(30026, "收货已完成,不要重复收货"),
    SHIP_NOT_COMPLETE(30027, "未发货不能收货"),
    NOT_EXPRESS_ORDER(30028, "不是物流订单"),
    SHIP_NOT_UPDATE_EXPRESS(30029, "已发货不能修改收货人信息"),
    PICK_UP_ORDER_NOT_EXPRESS(30030, "自提订单不要用物流发货"),
    EXPRESS_NOT_PICK_UP_ORDER(30031, "物流订单不要用自提备货"),
    VERIFICATION_CODE_NOT_EXISTS(30032, "核销码无效"),
    ORDER_PACKAGE_NOT_EXISTS(30033, "包裹不存在"),

    COMMENT_EXISTS(30034, "已评论不能重复评论"),
    COMPLETE_AFTER_ABLE_COMMENT(30035, "交易完成才可以评论"),
    MONEY_NO_OK(30036, "支付金额非法"),
    MONEY_NO_ZERO(30037, "支付金额为零,无需支付"),

    RIGHTS_ORDER_EXISTS(30050, "订单已存在维权"),
    RIGHTS_ORDER_NOT_EXISTS(30051, "维权订单不存在"),

    RIGHTS_CHILD_ORDER_NOT_EXISTS(30052, "维权子订单不存在"),
    NOT_PAY_NOT_RIGHTS(30053, "支付成功的订单才能申请退款"),
    SHIP_NOT_RECEIPT(30054, "已发货没有收货的订单不能申请维权"),
    NOT_SHIP_APPLY_RETURN(30055, "没有发货不能申请退货"),
    OVERFLOW_ORDER_FACT_COST(30056, "申请的维权金额不能超过实际金额%s元"),
    MAIN_ORDER_RIGHTS_REPEAT(30057, "已申请售后，请勿重复提交"),
    CHILD_ORDER_RIGHTS_REPEAT(30058, "该商品已申请售后，请勿重复提交"),
    ORDER_END(30059, "订单已关闭"),
    RIGHTS_GOODS_NUM_OVERFLOW(30060, "维权订单数量超出购买商品数量"),
    RIGHTS_ORDER_NOT_APPLY(30061, "只有刚刚申请的维权单,商家才可以同意或拒绝"),
    REFUND_RIGHTS_NOT_CANCEL(30062, "只有刚刚申请的退款维权单,会员才可以取消"),
    RETURN_RIGHTS_NOT_CANCEL(30063, "退款退货维权单,会员发货之后不能取消"),
    RIGHTS_NOT_SHIP(30064, "退款退货维权单还没有发货"),
    RIGHTS_AGREE_AFTER_SHIP(30065, "退款退货维权单同意后发货"),
    NOT_RIGHTS_RETURN(30066, "不是退款退货维权单"),
    RIGHTS_RETURN_ABLE_UPDATE_SHIP(30067, "退款退货维权单商家没有收货之前可以修改发货单"),
    AGREE_REFUND(30068, "退款单同意之后才可以退款"),
    SHOP_RECEIPT_REFUND(30069, "退款退货单收货之后才可以退款"),
    RIGHTS_ORDER_DISABLED(30070, "维权单无效"),
    RIGHTS_ORDER_IN_STOCK_EX(30071, "入库数量超过了实际维权商品数量"),
    RIGHTS_TYPE_ERROR(30072, "选择一种维权方式"),
    NOT_RECEIPT_APPLY_CHILD(30072, "没有收货不能申请子订单维权"),
    NOT_APPLY_NOT_AGREE(30073, "只能申请维权的状态才可以自动同意维权"),
    RETURN_SHIP_AFTER_NOT_CANCEL(30074, "退款退货维权单,会员发货之后不能取消"),
    REFUND_MONEY_NO_OK(30075, "退款金额不一致"),
    REPEAT_REFUND(30076, "退款已成功不要重复"),
    REFUND_MONEY_ZERO(30077, "零元订单不能申请退款"),
    OVERFLOW_ORDER_FACT_POINT(30078, "申请的退还积分不能超过实际所用积分:%s元"),
    PAY_REFUND_ORDER_NOT_EXISTS(30101,"退款支付单不存在"),
    EXPRESS_NOT(30102, "不是物流订单"),
    LOGISTICS_CHILD_NOT_RIGHTS(30079, "物流中的订单不能维权"),
    SHIP_NOT_RIGHTS(30080, "物流中的订单不能维权"),

    TEAM_NOT_EXISTS(30201,"组团不存在"),
    CREAT_SUCCESS_ABLE_JOIN(30202,"只有组团中的团队才可以加入"),
    TEAM_MEMBER_ENOUGH(30203,"人员已满"),
    TEAM_EXPIRE(30204,"参团时间已过期"),
    NO_START_NOT_ABLE_OPEN_TEAM(30205,"活动还没有开始"),
    ENDED_NOT_ABLE_OPEN_TEAM(30206,"活动已结束"),
    REPEAT_JOIN_TEAM(30207,"不要重复参团"),


    SERVICE_CARD_VERIFICATION_CODE_NOT_EXISTS(30301,"服务订单核销码不存在"),

    SERVICE_CARD_SHOP_NOT_SAME(30302,"服务订单不属于您的店铺"),
    SERVICE_CARD_USE_COMPLETE(30303,"服务订单已使用完成"),
    SERVICE_CARD_USE_EXPIRED(30304,"服务订单已过期"),
    NOT_SERVICE_ORDER(30305,"不是服务订单"),
    SERVICE_CARD_NOT_EXISTS(30306,"服务订单的服务卡不存在"),
    SERVICE_CARD_ORDER_NOT_SAME(30306,"该服务订单核销码不属于该服务订单"),
    APPOINTMENT_TIME_GT_NEW(30307,"预约时间需要在当前时间之后"),
    ;

    private Integer code;
    private String msg;
    OrderException(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }


    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @JsonCreator
    public static OrderException getByCode(int code) {
        for (OrderException value : OrderException.values()) {
            if (Objects.equals(code, value.getCode())) {
                return value;
            }
        }
        return null;
    }
}
